﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpShare.Afp.Protocol {
    [Serializable]
    public struct AfpUnixPrivileges {
        public uint uid;
        public uint gid;
        public AfpUnixPrivilegePermissions permissions;
        public AfpAccessRightsBitmap accessRights;
    }

    [Flags]
    public enum AfpUnixPrivilegePermissions : uint {
        /* File type */
        FileTypeMask = 0xF000,		/* [XSI] type of file mask */
        NamedPipe = 0x1000,		/* [XSI] named pipe (fifo) */
        CharacterSpecial = 0x2000,		/* [XSI] character special */
        Directory = 0x4000,		/* [XSI] directory */
        BlockSpecial = 0x6000,		/* [XSI] block special */
        Regular = 0x8000,		/* [XSI] regular */
        SymbolicLink = 0xA000,		/* [XSI] symbolic link */
        Socket = 0xC000,		/* [XSI] socket */

        /* File mode */
        /* Read, write, execute/search by owner */
        OwnerReadWriteExecute = 0x1C0,		/* [XSI] RWX mask for owner */
        OwnerRead = 0x100,		/* [XSI] R for owner */
        OwnerWrite = 0x80,		/* [XSI] W for owner */
        OwnerExecute = 0x40,		/* [XSI] X for owner */
        /* Read, write, execute/search by group */
        GroupReadWriteExecute = 0x38,		/* [XSI] RWX mask for group */
        GroupRead = 0x20,		/* [XSI] R for group */
        GroupWrite = 0x10,		/* [XSI] W for group */
        GroupExecute = 0x8,		/* [XSI] X for group */
        /* Read, write, execute/search by others */
        OtherReadWriteExecute = 0x7,		/* [XSI] RWX mask for other */
        OtherRead = 0x4,		/* [XSI] R for other */
        OtherWrite = 0x2,		/* [XSI] W for other */
        OtherExecute = 0x1,		/* [XSI] X for other */

        SetUserIdOnExecution = 0x800,		/* [XSI] set user id on execution */
        SetGroupIdOnExecution = 0x400,		/* [XSI] set group id on execution */
        DirectoryRestrictedDelete = 0x200		/* [XSI] directory restrcted delete */
    };

}
